package org.idontknow.blocks;

class PileOver extends Command {

	PileOver(Block _from, Block _to) {
		super(_from, _to);
	}

	public void execute() {
		log.info("Begin of \"PileOver\" command");
		int idStackFrom = blockFrom.getStackId();
		int posStackFrom = blockFrom.getPosInStack();
		int idStackTo = blockTo.getStackId();

		// System.out.println("the pile is on stack " + idStackFrom);
		// System.out.println("on stack " + idStackFrom + " there are: " +
		// Command.blockStack[idStackFrom].getNbBlocks() + " blocks in total");
		// System.out.println("block " + blockFrom.getValue() + " is at pos " +
		// posStackFrom + " on the stack");
		// System.out.println("the 'stackFrom' has " + stackFrom.getNbBlocks() +
		// " blocks");
		// stackFrom.print();
		// System.out.println("upon block " + blockFrom.getValue() + " there
		// are: " + stackFrom.getNbBlocksUpon(posStackFrom) + " blocks");
		log.info("Nothing to return for sure, moving blocks...");
		this.moveBlocksOver(idStackFrom, idStackTo, stackFrom
				.getNbBlocksUpon(posStackFrom) + 1);
		System.out.println("-------- Command: pile " + blockFrom.getValue()
				+ " over " + blockTo.getValue() + " --------");
		printStacks();
		log.info("End of \"PileOver\" command\n\n----------------------------------------");
	}
}
